#include<stdio.h>
#include<algorithm>
using namespace std;
struct time
{
	int year;
	int month;
	int day;
	int hour;
	int minute;
	int second;
};
struct time t[1005];
bool cmp(struct time a,struct time b)
{
	if(a.year!=b.year)
		return a.year<b.year;
	if(a.year==b.year&&a.month!=b.month)
		return a.month<b.month;
	else if(a.day!=b.day)
		return a.day<b.day;
	else if(a.hour!=b.hour)
		return a.hour<b.hour;
	else if(a.minute!=b.minute)
		return a.minute<b.minute;
	else
		return a.second<b.second;
	
}
int main()
{
	int n,i;
	scanf("%d",&n);getchar();
	for(i=0;i<n;i++)
		scanf("%d/%d/%d-%d.%d.%d",&t[i].year,&t[i].month,&t[i].day,&t[i].hour,&t[i].minute,&t[i].second);
	sort(t,t+n,cmp);
	for(i=0;i<n;i++)
		printf("%d/%d/%d-%d.%d.%d\n",t[i].year,t[i].month,t[i].day,t[i].hour,t[i].minute,t[i].second);
	return 0;
}
